﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace NotMyself.Oxite.Data.LinqToNHibernateProvider.Tests.Utility
{
    public static class XmlElementExtensions
    {
        public static string AttributeShouldEqual(this XmlElement element,
                                                  string attributeName,
                                                  string expected)
        {
            element.ShouldNotBeNull();

            string actual = element.GetAttribute(attributeName);
            actual.ShouldEqual(expected);
            return expected;
        }

        public static XmlElement ShouldHaveChild(this XmlElement element,
                                                 string xpath)
        {
            var child = element.SelectSingleNode(xpath) as XmlElement;
            child.ShouldNotBeNull();

            return child;
        }

        public static XmlElement DoesNotHaveAttribute(this XmlElement element,
                                                      string attributeName)
        {
            element.ShouldNotBeNull();
            element.HasAttribute(attributeName).ShouldBeFalse();

            return element;
        }
    }
}
